package com.example.springboot.demo.service;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;

/**
 * @author daifei
 * @date 2019/6/26
 */
public class ServerImportSelector implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {

        Map<String,Object> annotationAttributes = annotationMetadata.getAnnotationAttributes(EnableServer.class.getName());
        Server.type type = (Server.type) annotationAttributes.get("type");

        if (Server.type.HTTP.equals(type)){
            return new String[]{HttpServer.class.getName()};
        }else if(Server.type.FTP.equals(type)){
            return new String[]{FtpServer.class.getName()};
        }
        return null;
    }
}
